<script type="text/javascript" src="{$smarty.const.TEMPLATE_DIR}order_administration/order_administration.js"></script>
<script type="text/javascript">
	var linkToPlan = "{$smarty.const.URL_HOME}miesta";
	
</script>
{include_module controller="order_administration/statistics"}

<div class="ui-widget-content" style="float:left;padding: 10px; width: 1000px; margin: auto; background: none; border: none;">
<h3 class="ui-widget-header" style="margin-top: 0; text-align: center;"> 
			Správa objednávok 
</h3>
<div id="tabs">	
	<ul>
        <li><a href="#fragment-1"><span>Platba</span></a></li>
        <li><a href="#fragment-2"><span>Objednávka</span></a></li>
        <li><a href="#fragment-3"><span>Správa plánu</span></a></li>
        <li><a href="#fragment-4"><span>Správa rezervácii</span></a></li>
    </ul>
    
	<div id="fragment-1"  style="width: 100%; padding: 5px;"> 
		
		<div style="padding: 5px; padding-top: 0;">		
			{if isset($data.message)}
				<div class="ui-state-error" style="text-align: center;">
					<span class="ui-icon ui-icon-alert" style="float: left;">&nbsp;</span>
					{$data.message}
				</div>
			{/if}
			
			<form id="order_administration" action="order_administration?action=search" method="POST">
			<table style="width: 100%;">
					<tr>
						<td>
							<label > Hľadaj podľa: </label>
						</td>
						<td>
							<select  id="search_options" name="search_options">
								<option  value="email" selected="selected">Email</option>
								<option  value="user_name" >Meno</option>
								<option  value="id" >Číslo objednávky</option>
						    </select>
						</td>
						<td>
							<input class="input-text" id="search_value" type="text" name="search_value" />
						</td>
					</tr>
			</table>

			
			<button id="search">Hľadaj</button>
			
			{if isset($data.foundOrders)}
			<script type="text/javascript">
			$(document).ready(function(){
				   	
					$("#search_results").dataTable({
				        "bPaginate": false,
				        "bLengthChange": false,
				        "bFilter": false,
				        "bSort": true,
				        "bInfo": false,
				        "bAutoWidth": false
				    });
			   });
			</script>
			
			<table id="search_results" class="display" style="width: 100%;">
				 <thead><tr>
		            <th>Id objednávky</th>
		            <th>Používateľ</th>
		            <th>Email</th>
		            <th>Čas</th>
		            <th >Objednané miesta</th>
		            <th >Komentár</th>
		            <th>Zaplatené</th>
        		</tr>
        		</thead>
        		<tbody>
				{foreach from=$data.foundOrders item="order"}
					<tr id={$order -> id}>
						<td>
							{$order -> id}
						</td>
						<td>
							{$order -> user_name}
						</td>
						<td>
							{$order -> email}
						</td>
						<td style="width: 120px;">
							{formatDate time=$order -> created format="j. n. Y H:i:s" }
						</td>
						<td style="width: 120px;">
							
							P:{str_replace("-"," Stôl:", str_replace(",","Miesto:",str_replace(";","<br>P:",$order -> seats)))}
						</td>
						<td>
							{$order -> comment}
						</td>
						<td>
							{if ($order -> paid == 0)}
							 <input type="button" onclick="changeStatusToPaid('{$order -> id}')" value="Zaplatiť" />
							 <span name="paid" style="display:none">Zaplatené</span> 
							{else}
							
							 <span name="paid">Zaplatené</span>
							  
							{/if}
						</td>
					</tr>
				{/foreach}
				</tbody>
			</table>
			
			
			{/if}
			
			</form>
		</div>
	</div>
	<div id="fragment-2">
        <form id="admin_orders" action="order_administration?action=order" method="POST">
				<table id="order_table" style="width: 100%;">
					<thead>
						<tr>
							<th>
								<label > Plán</label>
							</th>
							<th>
								<label > Stôl</label>
							</th>
							<th>
								<label > Stolička </label>
							</th>
							
							<th>
								
							</th>
							
						</tr>
					</thead>
					<tbody>
					<tr>
						<td>
							<select  id="plan_number" name="plan_number">
									<option  value="1" selected="selected">východ</option>
									<option  value="2" >sever</option>
									<option  value="3" >juh</option>
							</select>
						</td>
						<td>
							<input class="input-text" id="table_number" type="text" name="table_number" />
						</td>
						<td>
							<input class="input-text" id="seat_number" type="text" name="seat_number" />
						</td>
						
						<td>
							<input type="button" onclick="addRowInOrder()" value="+" />
						</td>
						
					</tr>
					</tbody>
			</table>
			<div><label > Objednávka pre používateľa : </label><input  style="display:inline" id="name_order" type="text" name="name_order" /></div><br/>
			<input type="button" onclick="orderSeats()" value="Objednať" />
	  </form>
    </div>
    <div id="fragment-3">
        <table id="plan_setting" style="width: 100%;">
					<thead>
						<tr>
							<th>
								<label > Plán</label>
							</th>
							<th>
								
							</th>
							<th>
								
							</th>
							
						</tr>
					</thead>
					<tbody>
					<tr>
						<td>
							<select  id="plan_selection" name="plan_selection">
									<option  value="1" selected="selected">východ</option>
									<option  value="2" >sever</option>
									<option  value="3" >juh</option>
							</select>
						</td>
						<td>
							<input type="button" onclick="addNewRowInPlan()" value="Pridaj nový rad" />
						</td>
						<td>
							<input type="button" onclick="selectPlan()" value="Otvor plán" />
						</td>
					</tr>
					</tbody>
		</table>
    </div> 
     <div id="fragment-4">
        <table id="reservation_setting" style="width: 100%;">
					<thead>
						<tr>
							<th>
								<label > Akcia</label>
							</th>
							<th>
								<label > Plán</label>
							</th>
							<th>
								<label > Stôl</label>
							</th>
							<th>
								<label > Miesto</label>
							</th>
						</tr>
					</thead>
					<tbody>
					<tr>
						<td>
							<select  id="setting_action" name="setting_action">
									<option  value="1" selected="selected">Uvoľniť miesto</option>
									
							</select>
						</td>
						<td>
							<select  id="plan_settings" name="plan_settings">
									<option  value="1" selected="selected">východ</option>
									<option  value="2" >sever</option>
									<option  value="3" >juh</option>
							</select>
						</td>
						<td>
							<input type="text" id="table_id" name="table_id" />
						</td>
						<td>
							<input type="text" id="seat_id" name="seat_id" />
						</td>
					</tr>
					</tbody>
		</table>
		
	    <input type="button" onclick="unreserveSeat()" value="Uvoľniť" />
    </div> 
</div>
</div>





